package com.spirit.mypopup.pop;

import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;
import android.widget.PopupWindow;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction;

import com.spirit.mypopup.R;
import com.spirit.mypopup.popup.QMUIDisplayHelper;

import javax.net.ssl.TrustManagerFactory;

/**
 * author : fang.zhang
 * e-mail : initzf@126.com
 * date   : 2020/5/14
 * desc   :
 */
public class PopWindowWidget extends PopupWindow {
    private static final String TAG = "PopWindowWidget";
    private Context mContext;

    private ListView lvPopWindowList;

    private String[] countryGridCode = {"Test A", "Test B", "Test C", "Test D", "Test E", "Test F", "Test G", "Test H", "Test I"};
    private final int vWidth;
    private final int vHeight;

    public PopWindowWidget(Context mContext) {
        this.mContext = mContext;
        View view = LayoutInflater.from(mContext).inflate(R.layout.grid_code_pop_window_listview, null);

        lvPopWindowList = view.findViewById(R.id.lv_pop_window);
        lvPopWindowList.setDivider(null);                                                       //取消ListView分隔线
        lvPopWindowList.setVerticalScrollBarEnabled(false);                                     //隐藏侧滑栏
        lvPopWindowList.setAdapter(new GridCodePopWindowAdapter(countryGridCode, mContext));    //给弹窗ListView设置adapter

        setContentView(view);

        vWidth = QMUIDisplayHelper.getScreenWidth(mContext);
        vHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300f, mContext.getResources().getDisplayMetrics());

        setWidth(vWidth);
        setHeight(vHeight);

        setOutsideTouchable(false);
        setFocusable(true);
    }





    public void showPopWindow(View view) {

        showAsDropDown(view, view.getWidth(), 0);
    }


}
